namespace WinFormsApp1
{
    using System;
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void calculate1(object sender, EventArgs e)
        {
            string arry = arrys.Text;
            string[] imgArr = arry.Split(new char[] { ',' });
            int[] bty = Array.ConvertAll<string, int>(imgArr, delegate (string s) { return int.Parse(s); });
            int max = 0;
            float sum = 0;
            int min = 10000;
            foreach(int i in bty)
            {
                sum += i;
                if (max < i)
                {
                    max = i;
                }
                if (min > i)
                {
                    min = i;
                }
            }
            textBoxMax.Text = max.ToString();
            textBoxMin.Text = min.ToString();
            float Average = sum / bty.Length;
            textBoxAverage.Text = Average.ToString();
            textBoxSum.Text = sum.ToString();
        }

        private void calculate2(object sender, EventArgs e)
        {
            string a = "";
            List<int> myInts = new List<int>();
            int _bottom = int.Parse(top.Text)+1;
            int _top = int.Parse(bottom.Text);
            for (int i = _bottom; i < _top; i++)
            {
            bool b= true;
                for (int j = 2; j < i; j++)
                {
                    if (i % j == 0)
                    {
                     b = false;
                    }
                }
                if (b == true) {
                    a += " "+i.ToString();
                    myInts.Add(i);
                }
            }

            //richTextBox1.Text = a;
            //richTextBox1.Text =myInts[0].ToString();
            int cout = 0;
            for (int i = 0; i <=10; i++) {
                if (i == 10)
                {
                    i = 0;
                    richTextBox1.Text += "\r\n";
                }
                richTextBox1.Text += " "+myInts[cout].ToString();
                cout++;
                if (cout >= myInts.Count()){
                    break;
            }
            }
        }
    }
}